import plugin from "../../../lib/plugins/plugin.js";
import image from "../model/image.js";
import cfg from '../../../lib/config/config.js';
import Cfg from '../model/Cfg.js';
import syncMiaoMiaoHelp from '../model/Miao.js'; // 同步函数

export class example2 extends plugin {
    constructor() {
        super({
            name: '帮助插件',
            dsc: '更换更美观的帮助',
            event: 'message',
            priority: -114514,
            rule: [
                // 一键同步喵喵帮助
                {
                    reg: '^(#|/)?同步(喵喵)?帮助?$',
                    fnc: 'tbhelp'
                },
                // 替换帮助
                {
                    reg: '^(#|/)?(云崽|云宝|全部)?(帮助|菜单|help|功能|说明|指令|使用说明|命令)(列表)?$',
                    fnc: 'help'
                },
                {
                    reg: '^(#|/)?(云崽|云宝|全部)?(帮助|菜单|help|功能|说明|指令|使用说明|命令)(列表)?(pro|Pro|PRO)$',
                    fnc: 'helppro'
                },
                {
                    reg: '^(#|/)?(云崽|云宝|全部)?(js|JS|Js|example)(帮助|菜单|help|功能|说明|指令|使用说明|命令)(列表)?$',
                    fnc: 'jshelp'
                },
                {
                    reg: '^(#|/)?(云崽|云宝|全部)?(美图|图片|mt|ss|涩涩)(帮助|菜单|help|功能|说明|指令|使用说明|命令)(列表)?$',
                    fnc: 'sshelp'
                },

                //diy在以下新增


            ]
        });
    }

    async tbhelp(e) {
        if(!e.isMaster) return false
        await syncMiaoMiaoHelp();
        e.reply('喵喵帮助同步完成');
    }

    async sendHelpImage(e, type) {
        let _path = process.cwd().replace(/\\/g, '/');
        const config = Cfg.getconfig('config', type);
        let { img } = await image(e, 'help', type, {
            saveId: 'help',
            cwd: _path,
            genshinPath: `${_path}/plugins/help-plugin/resources/`,
            helpData: config,
            version: HelpPluginVersion
        });
        e.reply(img);
    }

    async help(e) {
        await this.sendHelpImage(e, 'help');
    }

    async helppro(e) {
        await this.sendHelpImage(e, 'helppro');
    }

    async jshelp(e) {
        await this.sendHelpImage(e, 'jshelp');
    }

    async sshelp(e) {
        await this.sendHelpImage(e, 'sshelp');
    }
}
